# 主程序：

from downloader_PR_SC import Downloader_PR_SC
import json
import pickle

# 测试代码：
dl = Downloader_PR_SC()
dl.set_limit_time("2022-01-01 00:00:00", "2022-12-31 23:59:59")
dl.set_keyword("遥感 中标公告")
doing = dl.try_get_datas()
print("records:", dl.get_records())
count = 0
while doing:
    datas = []
    datas = dl.get_datas()
    for d in datas:
        count += 1
        # print('解析后的数据:')
        # j_str = json.dumps(d,
        #                    default=lambda obj: obj.__dict__,
        #                    sort_keys=True,
        #                    indent=2,
        #                    ensure_ascii=False)
        # print(j_str)
        # print(d.tostring())
        # bytestr = pickle.dumps(d).encode('unicode_escape')
        # print(bytestr.decode('unicode_escape'))
        print(count, ',', dl.build_inner_link_url(d.linkurl), ',',
              d.publishTime, ',', d.createTime)
    # print("-----------------------------------------------------------")
    doing = dl.to_next_page()
